#include "pch.h"

#include "iosystem/win32/win32filetime.h"



namespace Win32
{

	///
	Win32FileTime::Win32FileTime()
	{
		this->m_time.dwLowDateTime = 0;

		this->m_time.dwHighDateTime = 0;
	}


	///
	Win32FileTime::Win32FileTime(const Helper::String &str)
	{
		Helper::Array<Helper::String> tokens = str.Tokenize("#");

		this->m_time.dwHighDateTime = tokens[0].GetAsInt();

		this->m_time.dwLowDateTime = tokens[1].GetAsInt();
	}



	///
	bool operator == (const Win32FileTime & a, const Win32FileTime & b)
	{
		return (0 == CompareFileTime(&a.m_time, &b.m_time));
	}


	///
	bool operator != (const Win32FileTime & a, const Win32FileTime & b)
	{
		return (0 != CompareFileTime(&a.m_time, &b.m_time));
	}

	///
	bool operator >  (const Win32FileTime & a, const Win32FileTime & b)
	{
		return (1 == CompareFileTime(&a.m_time, &b.m_time));
	}


	///
	bool operator <  (const Win32FileTime & a, const Win32FileTime & b)
	{
		return (-1 == CompareFileTime(&a.m_time, &b.m_time));
	}



	///
	Helper::String Win32FileTime::FileTimeAsString() const 
	{
		Helper::String result;

		result.Format("%d#%d", this->m_time.dwHighDateTime, this->m_time.dwLowDateTime);

		return result;
	}

}